/*
 *  NavierStokesSolver.h
 *  NSESolver
 *
 *  Created by Patrick Zulian on 3/3/11.
 *  Copyright 2011 ICS - USI - Lugano. All rights reserved.
 *
 */

#ifndef NSESolver_NavierStokesSolver_H
#define NSESolver_NavierStokesSolver_H


#include <string>

#include "Reference.h"
#include "Types.h"



#include "CFDProblem.h"

#include "NSEWriter.h"

namespace nsesolver {
	
	/**
	 * \brief The NavierStokesSolver class ... TODO Doc
	 */ 
	class NavierStokesSolver {
    private:
        Reference< AbstractWriter > writer;
	public:
        NavierStokesSolver();
		~NavierStokesSolver();
		
        inline void setWriter(AbstractWriter * writer)
        {
            this->writer = writer;
        }
		
		void solve(CFDProblem &problem,const double t0,const double tEnd,const double omega,const double Re,const double gx,const double gy);
        
		
        //private:
		double computeResidual(const CFDProblem &problem, const Matrixd &rhs) const;
        void SORStep(CFDProblem &problem, const Matrixd &rhs, const double omega);
		void SORSolve(CFDProblem &problem, const Matrixd &rhs, const double omega);
        void computeRHS(Matrixd &rhs, const CFDProblem &problem, const Matrixd F, const Matrixd G, const double tau );
        void updateVelocities(CFDProblem &problem, const Matrixd &G, const Matrixd &F, const double tau);
        void computeFandG(Matrixd &F, Matrixd &G, CFDProblem & problem, const double tau, const double ReInv, const double gx, const double gy);
	};
	
	
}

#endif //NSESolver_NavierStokesSolver_H
